﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form5 : Form
    {
        private string name = "";
        public Form5(string namestr)
        {
            name = namestr;
            InitializeComponent();
        }

        private void Form5_Load(object sender, EventArgs e)
        {
            webBrowser1.BackColor = System.Drawing.Color.Red;

            this.StartPosition = FormStartPosition.CenterScreen;
            Mydb mydb = new Mydb();
            var dt = mydb.getG_Fault(name);
            string G_Fault = dt.Rows[0]["G_Fault"].ToString();
            string G_Img = dt.Rows[0]["G_Img"].ToString();

            if (G_Img == "0")
            {
                webBrowser1.Visible = false;
                textBox3.Visible = true;
                textBox3.Text = G_Fault.Replace("[^]", "'");
            }
            else
            {
                webBrowser1.Visible = true;
                textBox3.Visible = false;

                webBrowser1.DocumentText = "<body style='background-color: #C7EDCC;'>" + G_Fault.Replace("[^]", "'").Replace("\r\n", "<br/>").Replace(" ", "&nbsp;") + "</body>";
            }
            
            mydb.coleconn();
        }


        protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
        {

            int WM_KEYDOWN = 256;

            int WM_SYSKEYDOWN = 260;

            if (msg.Msg == WM_KEYDOWN | msg.Msg == WM_SYSKEYDOWN)
            {
                switch (keyData)
                {
                    case Keys.Escape:
                        this.Close();//esc关闭窗体
                        break;
                }
            }
            return false;
        }

        private void textBox3_DoubleClick(object sender, EventArgs e)
        {
            textBox3.Focus();
            textBox3.SelectAll();
        }
    }
}
